//package com.example.demo.Exception;
//
//
//
//import com.example.demo.pojo.JsonResult;
//import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.converter.HttpMessageNotReadableException;
//import org.springframework.web.bind.MissingServletRequestParameterException;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.ResponseStatus;
//
//
//import java.time.format.DateTimeParseException;
//
//
////@ControllerAdvice
////@ResponseBody
////
////public class GlobalExceptionHandler {
////    private static final Logger logger= LoggerFactory.getLogger(GlobalExceptionHandler.class);
////    /**
////     * 缺少请求参数异常
////     * @param ex HttpMessageNotReadableException
////     * @return
////     */
////    @ExceptionHandler(MissingServletRequestParameterException.class)
////    @ResponseStatus(value = HttpStatus.BAD_REQUEST)
////    public JsonResult handleHttpMessageNotReadableException(
////            MissingServletRequestParameterException ex) {
////        logger.error("缺少请求参数，{}", ex.getMessage());
////        return new JsonResult("400", "缺少必要的请求参数");
////    }
////
////    @ExceptionHandler(MessagingException.class)
////    @ResponseStatus(value = HttpStatus.BAD_REQUEST)
////    public JsonResult MessagingException(
////            MessagingException ex) {
////        logger.error("联系邮件不正确!，{}", ex.getMessage());
////        return new JsonResult("400", "联系邮件不正确");
////    }
////    /**
////     * 空指针异常
////     * @param ex NullPointerException 需要捕捉的异常
////     * @return
////     */
////    @ExceptionHandler(NullPointerException.class)
////    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
////    public JsonResult handleTypeMismatchException(NullPointerException ex) {
////        logger.error("空指针异常，{}", ex.getMessage());
////        return new JsonResult("500", "服务器错误!请检查操作是否正确或稍后再试!");
////    }
////    @ExceptionHandler(HttpMessageNotReadableException.class)
////    @ResponseStatus(value =HttpStatus.INTERNAL_SERVER_ERROR)
////    public JsonResult HttpMessageNotReadableException(HttpMessageNotReadableException e){
////        logger.error("前端参数格式错误，{}", e.getMessage());
////        return new JsonResult("500", "服务器错误!请检查输入的参数是否正确!");
////    }
//
////    @ExceptionHandler(AuthorizationException.class)
////    @ResponseStatus(value = HttpStatus.UNAUTHORIZED)
////    public JsonResult AuthorizationException(AuthorizationException ex){
////        logger.error("无权限，{}", ex.getMessage());
////        return new JsonResult("401", "用户无权限访问该资源");
////    }
////    @ExceptionHandler(UnknownAccountException.class)
////    /**
////     *   设置返回的状态码
////     */
////    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
////    public JsonResult UnknownAccountException(UnknownAccountException e){
////        logger.error("无用户,{}", e.getMessage());
////        return  new JsonResult("500","用户名或密码错误!");
////    }
////    @ExceptionHandler(TokenExpiredException.class)
////    @ResponseStatus(value = HttpStatus.BAD_GATEWAY)
////    public JsonResult TokenExpiredException(TokenExpiredException e){
////        logger.error("令牌已过期,{}", e.getMessage());
////        return  new JsonResult("502","令牌已过期!");
////    }
////    @ExceptionHandler(HttpMessageNotReadableException.class)
////    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
////    public JsonResult HttpMessageNotReadableException(HttpMessageNotReadableException e){
////        logger.error("无法获得请求参数.{}", e.getMessage());
////        return  new JsonResult("401","无法获得请求参数!");
////    }
////    @ExceptionHandler(IncorrectCredentialsException.class)
////    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
////    public JsonResult IncorrectCredentialsException(IncorrectCredentialsException e){
////        logger.error("密码错误.{}", e.getMessage());
////        return  new JsonResult("401","密码错误,登陆失败!");
////    }
//
//
//
//
//}
